<?php
/**
 * @copyright   Copyright (C) Open Web Software Ltda. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');
$activeLang = $this->language;

$bodyClass = "site";
$bodyClass .= ($option != "")     ? " " . $option : "";
$bodyClass .= ($view != "")       ? " view-" . $view : "";
$bodyClass .= ($layout != "")     ? " layout-" . $layout : "";
$bodyClass .= ($task != "")       ? " task-" . $task : "";
$bodyClass .= ($itemid != "")     ? " itemid-" . $itemid : "";
$bodyClass .= ($activeLang != "") ? " lang-" . $activeLang : "";

if(!class_exists('Mobile_Detect')) {
  include 'tools/Mobile_Detect.php';
}
$detect = new Mobile_Detect();

if($detect->isMobile() && !$detect->isTablet()){
  include 'index.mobile.php';
}
else
{

// Add JavaScript Frameworks
// JHtml::_('bootstrap.framework');

  include 'tools/Browser_Detect.php';
// Add Stylesheets

// Compilar LESS y usar en produccion
// $doc->addStyleSheet('templates/'.$this->template.'/css/template.css');

  $doc->addStyleSheet('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css', $type = 'text/css');
  //$doc->addStyleSheet($this->baseurl . 'templates/'.$this->template.'/css/template.css', $type = 'text/css');

  if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/templates/'.$this->template.'/css/browser-' . strtolower(browserDetect()) . '.css')){
    $doc->addStyleSheet($this->baseurl . 'templates/'.$this->template.'/css/browser-' . strtolower(browserDetect()) . '.css', $type = 'text/css');
  }

  $doc->addScript('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', 'text/javascript');
  $doc->addScript($this->baseurl . '/media/jui/js/jquery-noconflict.js', 'text/javascript');
  $doc->addScript('//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js', 'text/javascript');
  ?>
  <!DOCTYPE html>
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <jdoc:include type="head" />
    <link rel="stylesheet" href="/templates/ow-agrikulturo/css/template.less" type="text/less" />
    <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js" type="text/javascript"></script>
  </head>
  <body class="<?php echo $bodyClass;?>">
    <div class="accessibility">
      <ul>
        <li><a href="#nav01"><?php echo JText::_('TPL_OW-AGRIKULTURO_JUMP_TO_NAV'); ?></a></li>
        <li><a href="#content"><?php echo JText::_('TPL_OW-AGRIKULTURO_JUMP_TO_CONTENT'); ?></a></li>
      </ul>
    </div>
    <?php if(!$editMode){ ?>
    <header id="header">
      <div class="container">
        <?php if ($this->countModules('logo')) : ?>
        <div id="logo"><jdoc:include type="modules" name="logo" style="none" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules('tagline')) : ?>
        <div id="tagline"><jdoc:include type="modules" name="tagline" style="none" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules('search')) : ?>
        <div id="search"><jdoc:include type="modules" name="search" style="none" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules('nav01')) : ?>
        <div id="nav01"><jdoc:include type="modules" name="nav01" style="html5" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules('nav02')) : ?>
        <div id="nav02"><jdoc:include type="modules" name="nav02" style="html5" /></div>
        <?php endif; ?>
        
        <?php if ($this->countModules('social')) : ?>
        <div id="social"><jdoc:include type="modules" name="social" style="none" /></div>
        <?php endif; ?>
      </div>
    </header>
    <?php } ?>
    <div class="container">
      <div class="row">
        <div class="span3">
          <!--Sidebar content-->
        </div>
        <div id="content" class="span9">
          <!--Body content-->
          <jdoc:include type="message" />
          <jdoc:include type="component" />
        </div>
      </div>
    </div>
    <footer>
      <div class="container">
      </div>
    </footer>
    <jdoc:include type="modules" name="debug" style="none" />
    <div class="accessibility">
      <ul>
        <li><a href="#header"><?php echo JText::_('TPL_OW-AGRIKULTURO_JUMP_TO_TOP'); ?></a></li>
        <li><a href="#nav01"><?php echo JText::_('TPL_OW-AGRIKULTURO_JUMP_TO_NAV'); ?></a></li>
        <li><a href="#content"><?php echo JText::_('TPL_OW-AGRIKULTURO_JUMP_TO_CONTENT'); ?></a></li>
      </ul>
    </div>
  </body>
  </html>
  <?php
}
?>